<%@page import="java.util.Enumeration"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page contentType="text/html; charset=utf-8" language="java"
	import="java.sql.*" errorPage=""%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>TracSetup</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="webmasterneo" />
<meta name="description"
	content="A short description of your site here." />
<link rel="stylesheet" href="style.css" type="text/css" />
<%
	String cognome = request.getParameter("cognome");
	String nome = request.getParameter("nome");
	String email = request.getParameter("email");
	String progetto = request.getParameter("progetto");
	String cerca = request.getParameter("cerca");
	String params = "";
	if (cerca != null) {
		params += "&cerca=true&cognome=" + cognome + "&nome=" + nome
				+ "&email=" + email;
		if (progetto != null && !progetto.equals("-1")) {
			params += "&progetto=" + progetto;
		}

	}
	request.setAttribute("params", params);
%>
<script type="text/javascript" src="scripts/prototype.js"></script>
<script type="text/javascript" src="scripts/tts.js"></script>

</head>

<body>

<div id="header">
<div class="header"></div>
</div>

<div id="menu">
<div class="menu"><a href="listaUtenti.do">Elenco utenti</a></div>
<div class="menu"><a href="esci.do">Esci</a></div>
<div class="menu"></div>
<div class="menu"></div>
<div class="menu"></div>
</div>

<div id="body">
<div class="spacer"></div>
<div class="content">
<form accept-charset="UTF-8" action="cercaUtente.do"
	id="formCercaUtente" method="post">
<table width="600" border="1" align="center">
	<tr>
		<td>Cognome</td>
		<td><input type="text"
			value="<c:out value='${param.cognome }' />" name="cognome" /></td>
	</tr>
	<tr>
		<td>Nome</td>
		<td><input type="text" value="<c:out value='${param.nome }' />"
			name="nome" /></td>
	</tr>
	<tr>
		<td>Email</td>
		<td><input type="text" value="<c:out value='${param.email }' />"
			name="email" /></td>
	</tr>
	<tr>
		<td>Progetto</td>
		<td><select name="progetto">
			<option value="-1">-- selezionare --</option>
			<c:forEach items="${progetti}" var="item">
				<option value="<c:out value='${item.idProgetto }'/>"><c:out
					value='${item.descrizione}' /></option>

			</c:forEach>
		</select></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="submit" name="cerca"
			value="Cerca" /></td>
	</tr>
</table>
</form>


</p>
<c:choose>
	<c:when test="${not empty listaUtenti}">
		<%
			if (request.getAttribute("passwordAzzerata") != null) {
		%>
		<table width="100%">
			<tr>
				<td><%=request.getAttribute("passwordAzzerata")%></td>
			</tr>
		</table>
		<%
			}
		%>
		<table width="100%">
			<tr style="border-bottom: thin">
				<td>USERNAME</td>
				<td>NOME</td>
				<td>COGNOME</td>
				<td>EMAIL</td>
				<td>PROFILO</td>
				<td>PROGETTI</td>
				<td>TICKETS</td>
				<td></td>
				<td></td>
			</tr>

			<c:forEach items="${listaUtenti}" var="item">
				<tr>
					<td><c:out value="${item.username}" /></a></td>
					<td><c:out value="${item.cognome}" /></td>
					<td><c:out value="${item.nome}" /></td>
					<td><c:out value="${item.email}" /></td>
					<td><c:out value="${item.profilo.descrizione}" /></td>
					<td></td>
					<td></td>
					<td><c:if
						test="${item.profilo.descrizione=='USER' || item.profilo.descrizione=='DEVELOPER'}">
						<a
							href="azzeraPassword.do?id=<c:out value='${item.idUtente}'/><c:out value='${params }'/>">Azzera
						password</a>
					</c:if></td>
					<td>
					<%
						Enumeration paramNames = request.getParameterNames();
									StringBuffer parameters = new StringBuffer();
									while (paramNames.hasMoreElements()) {
										String name = (String) paramNames.nextElement();
										String value = request.getParameter(name);
										parameters.append(name).append("=").append(value)
												.append("&");
									}
									if (parameters.indexOf("&") != -1) {
										parameters = new StringBuffer(parameters.substring(
												0, parameters.lastIndexOf("&")));
									}
					%> <c:if test="${item.profilo.descrizione!='ADMINISTRATOR'}">
						<c:choose>
							<c:when test="${item.abilitato }">
								<a
									href="javascript:changeStatoUtente('<c:out value="${item.idUtente }"/>','false','cercaUtente.do','<%=parameters.toString()%>')">
								Disabilita </a>
							</c:when>
							<c:otherwise>
								<a
									href="javascript:changeStatoUtente('<c:out value="${item.idUtente }"/>','true','cercaUtente.do','<%=parameters.toString()%>')">
								Abilita </a>
							</c:otherwise>
						</c:choose>
					</c:if></td>
				</tr>
			</c:forEach>
			<table>
				<tr>
					<td align="right"><c:if test="${!currentPage.firstPage }">
						<a
							href="listaUtenti.do?p=<c:out value='${prevPage }' />&action=prev<c:out value='${params }'/>">prev</a>
					</c:if> <c:if test="${!currentPage.firstPage && !currentPage.lastPage }">	
				|</c:if> <c:if test="${!currentPage.lastPage }">
						<a
							href="listaUtenti.do?p=<c:out value='${nextPage }' />&action=next<c:out value='${params }'/>">next</a>
					</c:if></td>
					<td>Pagina <c:out value="${currentPage.page }" /> di <c:out
						value="${currentPage.pagineTotali}" /></td>
				</tr>
			</table>
		</table>
	</c:when>
	<c:otherwise>
		Nessun ticket trovato
	</c:otherwise>
</c:choose></div>


<div class="spacer"></div>
<div id="footer">
<div class="footer"></div>
&copy; Copyright 2010 Setup s.r.l. All Rights Reserved.</div>
</div>

</body>

</html>
